package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFile;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    //菜品分页查询
    Page<DishVO> queryDish(DishPageQueryDTO dishPageQueryDTO);
    //根据id查询dish菜单
    Dish getDish(Long id);
    //根据id查询菜的口味
    List<DishFlavor> getFlavors(Long id);
    //根据id查询查询种类
    List<Dish> getDishByCategoryId(Integer id);
    //根据id查询是否能够删除--判断有没有起售中的菜品
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);
    //根据主键删除菜品数据
    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);
    //插入基本数据
    @AutoFile(value = OperationType.INSERT)
    void saveBaseDish(Dish dish);
    //插入口味数据
    void saveFlavors(List<DishFlavor> flavors);

    void updateBaseDish(Dish dish);

    void saveOrUpdate(Integer status,Integer id);

    List<Dish> list(Dish dish);
}
